package zhangyu.world.voltaic.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import zhangyu.world.voltaic.utils.JsonResult;
import zhangyu.world.voltaic.utils.RedisUtil;
import zhangyu.world.voltaic.entity.Admin;
import zhangyu.world.voltaic.mapper.AdminMapper;
import zhangyu.world.voltaic.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shane
 * @since 2020-03-30
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Autowired
    private AdminMapper adminMapper;
    @Autowired
    private RedisUtil redisUtil;

    @Override
    public JSONObject test() {

        Object o = redisUtil.get("2-1");
        JSONObject json = JSONObject.parseObject(o.toString());
        QueryWrapper wrapper=new QueryWrapper();


        IPage<Admin> page = new Page(1, 8);
        IPage iPage = adminMapper.selectPage(page, wrapper);
        Admin admin=new Admin();
        admin.setAdminAccount("dsfsadf");

        adminMapper.insert(admin);
        return JsonResult.successJson(iPage);
    }
}
